package root.electronclass.electronclass.common.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.AnimationDrawable;
import android.media.Image;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;


import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import root.electronclass.electronclass.R;
import com.facebook.common.util.UriUtil;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.Timer;
import java.util.TimerTask;

public class HttpLoadingDialog extends Dialog {

    private ImageView mIvLoading;
    private AnimationDrawable loadingAnim;
    private DraweeController draweeController;
    private Context context;

    public HttpLoadingDialog(Context context) {
        super(context, R.style.K12DialogStyle);
        this.context =  context;
    }

    public HttpLoadingDialog(Context context, String msg) {
        super(context, R.style.K12DialogStyle);
        this.context =  context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setCancelable(false);
        setCanceledOnTouchOutside(false);
        setContentView(R.layout.dialog_loading_http);
        init();
    }

    public void init() {
        mIvLoading = findViewById(R.id.iv_loading);
    }

    @Override
    public void show() {
        super.show();
        Glide.with(context)
                .asGif()
                .load(R.mipmap.load)
                .into(mIvLoading);
    }

    @Override
    protected void onStop() {
        super.onStop();
        Glide.with(context).clear(mIvLoading);
    }

    @Override
    public void dismiss() {
        super.dismiss();
        Glide.with(context).clear(mIvLoading);
    }


}
